//
//  SMAccountCollectView.m
//  lishiminOC
//
//  Created by p2p on 16/10/14.
//  Copyright © 2016年 p2p. All rights reserved.
//

#import "SMAccountCollectView.h"

@interface SMAccountCollectView()
@property (nonatomic,strong)UIImageView *titleImageView;
@property (nonatomic,strong)UILabel *titleTextLabel;
@property (nonatomic,strong)UIButton *clickButton;
@property (nonatomic,strong)UIView *intervalView;
@end
@implementation SMAccountCollectView

- (instancetype)init {
    self = [super init];
    if (self) {
        //设置界面
        [self setupUI];
    }
    return self;
}
#pragma mark - 设置界面
- (void)setupUI{
    UIImageView *titleImageView = [[UIImageView alloc]init];
    self.titleImageView = titleImageView;
    [self addSubview:titleImageView];
    
    UILabel *titleTextLabel = [[UILabel alloc]init];
    titleTextLabel.textColor = [UIColor redColor];
    titleTextLabel.textAlignment = NSTextAlignmentCenter;
    titleTextLabel.font = [UIFont systemFontOfSize:14];
    self.titleTextLabel = titleTextLabel;
    [self addSubview:titleTextLabel];
    
    UIView *intervalView = [[UIView alloc]init];
    intervalView.backgroundColor = [UIColor orangeColor];
    self.intervalView = intervalView;
    [self addSubview:intervalView];
    
    UIButton *clickButton = [[UIButton alloc]init];
    clickButton.backgroundColor = [UIColor clearColor];
    [clickButton setTitle:@"" forState:UIControlStateNormal];
    [clickButton addTarget:self action:@selector(touchUpInTheAction) forControlEvents:UIControlEventTouchUpInside];
    self.clickButton = clickButton;
    [self addSubview:clickButton];
    
    
    
    
}

- (void)layoutSubviews{
    
    __weak __typeof(&*self)weakSelf = self;
    [self.titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.width.mas_equalTo(@30);
        make.height.mas_equalTo(@25);
        make.top.equalTo(weakSelf.mas_top).with.offset(10);
    }];
    
    [self.titleTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.width.mas_equalTo(@40);
        make.top.equalTo(weakSelf.titleImageView.mas_bottom).with.offset(10);
        
    }];
    [self.clickButton mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.top.equalTo(weakSelf.mas_top);
        make.bottom.equalTo(weakSelf.mas_bottom);
        make.left.equalTo(weakSelf.mas_left);
        make.right.equalTo(weakSelf.mas_right);
        
    }];
    
    [self.intervalView mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.width.mas_equalTo(@1);
        make.top.equalTo(weakSelf.mas_top).with.offset(15);
        make.bottom.equalTo(weakSelf.mas_bottom).with.offset(-15);
        make.right.equalTo(weakSelf.mas_right);
    }];
}


- (void)setCellImageWithName:(NSString *)nameImageString andNameTitle:(NSString *)nameTitleString{
    self.titleImageView.image = [UIImage imageNamed:nameImageString];
    self.titleTextLabel.text = nameTitleString;
}
- (void)setViewWithArray:(NSDictionary *)dataDic andDisplayIntervalView:(BOOL)isDispaly{
    self.titleImageView.image = [UIImage imageNamed:dataDic[@"imageNameString"]];
    self.titleTextLabel.text = dataDic[@"titleNameLabel"];
    self.intervalView.hidden = isDispaly;
}
- (void)touchUpInTheAction{
    NSLog(@"%@",self.titleTextLabel.text);
}
@end
